var util = require('../../../../utils/util.js');
var api = require('../../../../config/api.js');
var pay = require('../../../../services/pay.js');

Page({
  data: {
    orderInfo: '',
    statusMemo:'',
    statusList:null,
    loadingHidden:false
 
  },
  orderId: '',
  statusMaps:{},
  
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数status
    console.log(options)
    var that = this;
    if (options.orderId) {
      that.orderId = options.orderId
    }
    //获取订单详情
    that.getOrderDetail();
    
    


  },
  getRefundProcess:function(){

    var that = this
    var data={}
    data.orderId = that.orderId

    util.request(api.RefundProcess, data,'POST').then(function(res){
        console.log(res)
        if(res.code==200){

            var statusList = res.responseBody

            for(var index=0;index<statusList.length;index++){

              if (!statusList[index].operateTime){
                statusList[index].operateTime='客服审批'
              }
              
              if(statusList[index].selected){
                statusList[index].lineShow =  true           
              }else{
                statusList[index].lineShow = false
                if(index>=1){
                  statusList[index - 1].lineShow = false
                }
              }
            }
            

            that.setData({
              statusList: statusList,
              loadingHidden : true
            })
        } 
    })

  },
 

  getOrderDetail: function () {
    var that = this;
    var data = {};
    data.orderId = that.orderId;
    util.request(api.RefundDetail + that.orderId).then(function (res) {
      console.log("订单详情返回值")
      console.log(res);

      //获取退款进度
      that.getRefundProcess();
      
      that.setData({
        orderInfo: res.responseBody //兼容水哥代码
      });

    });
  },
    

  onReady: function () {
    // 页面渲染完成
  },
  onShow: function () {
    // 页面显示
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  }
})